<!--
el-rate的默认值是0 比较不好用，我希望是null
-->
<template>
  <el-rate v-model="rateValue" v-bind="$attrs" v-on="$listeners" @click.native="clickMe"></el-rate>
</template>

<script>
export default {
    name: 'mc-rate',
    data () {
        return {
            rateValue :  this.value
        }
    },
    props:{
        //此处的value 就是父亲的v-model
        'value' : {type:Number,default:null}
    },
    watch:{
        rateValue(newValue){
            if(newValue==0){
                this.$emit("input",null);
            }
        },
        value(newValue){
            if(newValue==null){
                this.rateValue = 0;
            }else{
                this.rateValue = newValue;
            }
        }
    },
    mounted () {
        if(this.rateValue==0){
            this.$emit("input",null);
        }
    },
    methods:{
        clickMe(){
            /*if(this.rateValue!==0){
                this.rateValue = 0;
            }*/
        }
    }
}
</script>

<style lang="scss">

</style>
